import peewee
from peewee import *
from dotenv.main import load_dotenv
import os

load_dotenv()
database = MySQLDatabase(os.getenv('MYSQL_DB'), host=os.getenv('MYSQL_HOST'), user=os.getenv('MYSQL_USER'), password=os.getenv('MYSQL_PASSWORD'), charset=os.getenv('MYSQL_CHARSET'))

class BaseModel(peewee.Model):
    class Meta():
        database = database
    
class AnAtt(BaseModel):
    id = peewee.AutoField()
    an_id = peewee.CharField()
    att_name = peewee.CharField()
    att_path = peewee.CharField()
    att_url = peewee.CharField()
    an_file_path_id = peewee.CharField()
    status = peewee.CharField(default=0)
    content = peewee.TextField()

    class Meta:
        table_name = 'AN_ATT_PATH'

class AnFile(BaseModel):
    id = peewee.AutoField()
    an_id = peewee.CharField()
    uid = peewee.CharField()                # 项目ID
    an_type_id = peewee.CharField()         # 公告类型
    an_name = peewee.CharField()            # 公告名称
    pur_person_name = peewee.CharField()    # 采购人
    html_path = peewee.CharField()          # 公告地址
    date = peewee.DateField()               # 公告发布日期
    text = peewee.TextField()               # 公告内容
    pro_num = peewee.CharField()            # 项目编号
    pro_name = peewee.CharField()           # 项目名称
    province = peewee.CharField()           # 省份（1江西，2广东）

    class Meta:
        table_name = 'AN_FILE_PATH'

class User(BaseModel):
    id = peewee.AutoField()
    username = peewee.CharField()
    nickname = peewee.CharField()
    mobile = peewee.CharField()
    password = peewee.CharField()
    
    class Meta:
        table_name = 'user'